package org.komarichin.jpa.dao;

import org.komarichin.jpa.entity.IRole;
import org.komarichin.jpa.entity.IUser;

import java.util.List;

/**
 * User: Michael Komarichin
 * Date: 28.09.2009
 * Time: 13:37:02
 */
public interface IUserDAO {
    /**
     * find user by it id
     *
     * @param id news id
     * @return found news
     */
    IUser getUserById(Long id);

    /**
     * find user by customer permission
     *
     * @param permission customer permission
     * @return found users
     */
    List<IUser> getAllowUsers(Long permission);

    /**
     * @return all users in list, if users not exists then list will empty with size 0
     */
    List<IUser> getAll();

    /**
     * @param object save persistence user
     */
    void save(IUser object);

    /**
     * @param object update news
     */
    void update(IUser object);

    /**
     * @param object save or update user if user exists then it will be save
     */
    void saveOrUpdate(IUser object);

    /**
     * @param object delete user
     */
    void delete(IUser object);

    /**
     * Create new user
     *
     * @param login    user login
     * @param password user password
     * @param hint     user hint
     * @param role     user role
     * @return new created user
     */
    IUser enroll(String login, String password, String hint, IRole role);

    /**
     * find user by login and password
     *
     * @param login    user login
     * @param password user password
     * @return found user or null
     */
    IUser login(String login, String password);

    /**
     * find user by login and hint if user lost your password
     *
     * @param login user login
     * @param hint  user hint
     * @return found user or null
     */
    IUser forgot(String login, String hint);

    /**
     * find user by login
     *
     * @param login user login
     * @return found user
     */
    IUser findByName(String login);

    /**
     * check user in bd
     *
     * @param login user login
     * @return true if user exists
     */
    boolean isUserExists(String login);
}
